import { uploadPath } from "@/api/currency";

export default {
  selector: "#articleEditor", //DOM选择器
  statusbar: false, // 隐藏编辑器底部的状态栏
  elementpath: false, //禁用下角的当前标签路径
  paste_data_images: true, // 允许粘贴图像
  branding: false, // 去水印
  table_default_styles: {
    width: "100%",
    borderCollapse: "collapse"
  },
  height: 800, //高度
  language: "zh_CN", //语言设置
  menubar: false, // 隐藏最上方menu菜单
  plugins: [
    "advlist anchor autolink autosave code codesample  directionality emoticons fullscreen hr image imagetools importcss insertdatetime link lists media nonbreaking noneditable pagebreak paste preview print save searchreplace spellchecker tabfocus table template  textpattern visualblocks visualchars wordcount code indent2em code lineheight"
  ],
  toolbar: [
    " undo redo|fullscreen searchreplace preview |  bold italic underline strikethrough hr | formatselect  alignleft aligncenter alignright | indent2em lineheight outdent indent | blockquote removeformat subscript superscript code codesample",
    " bullist numlist | link image media | charmap  anchor pagebreak insertdatetime  table emoticons forecolor backcolor | fontselect fontsizeselect  "
  ], //false禁用工具栏（隐藏工具栏）
  images_upload_handler: function(blobInfo, success, failure) {
    var xhr, formData;
    xhr = new XMLHttpRequest();
    xhr.withCredentials = false;
    xhr.open("POST", uploadPath);
    xhr.onload = function() {
      var json;

      if (xhr.status != 200) {
        failure("HTTP Error: " + xhr.status);
        return;
      }
      json = JSON.parse(xhr.responseText);
      json = json.data;
      if (!json || typeof json.src !== "string") {
        failure("Invalid JSON: " + xhr.responseText);
        return;
      }
      success(json.src);
    };
    formData = new FormData();
    formData.append("file", blobInfo.blob(), blobInfo);
    xhr.send(formData);
  }
};
